import type * as Auth from "./type"
import { request } from "@/http/axios"
import {LoginByCodeRequestData} from "./type";

/** 获取登录验证码 */
export function getCaptchaApi() {
  return request<Auth.CaptchaResponseData>({
    url: "auth/captcha",
    method: "get"
  })
}

/** 登录并返回 Token */
export function loginApi(data: Auth.LoginRequestData) {
  return request<Auth.LoginResponseData>({
    url: "applogin",
    method: "post",
    data
  })
}

export function sendMsgApi (data: Auth.LoginByCodeRequestData) {
  return request<Auth.SendMsgResponseData>({
    url: "sendsmstencenttest",
    method: "post",
    data
  })
}
/** 注册并返回 Token  */
export function registerApi(data: Auth.RegisterRequestData) {
  return request<Auth.LoginResponseData>({
    url: "appregister",
    method: "post",
    data
  })
}

// forgetApi
export function forgetApi(data: Auth.ForgetRequestData) {
  return request<Auth.ForgetResponseData>({
    url: "resetpassword",
    method: "post",
    data
  })
}

// sendCodeApi
export function sendCodeApi(data: Auth.SendCodeRequestData) {
  return request<Auth.SendCodeResponseData>({
    url: "sendsmstencent",
    method: "post",
    data
  })
}

// loginByCodeApi
export function loginByCodeApi(data: Auth.LoginByCodeRequestData) {
  return request<Auth.LoginResponseData>({
    url: "loginandregister",
    method: "post",
    data
  })
}
